#ifndef SERIALPORTHELPER_H
#define SERIALPORTHELPER_H

#include <QObject>
#include <QSerialPort>
#include <QSerialPortInfo>
#include "testmodel.h"
#include "portlist.h"
//#include "device.h"
#include "devicelist.h"
#include "hostlist.h"
//#include "devicelistmodel.h"
//#include "serialport.h"
#include "seriallist.h"
#include "networklist.h"
//#include "dataclass.h"
#include "flowmeter.h"
#include "hj212.h"
#include "checkupdate.h"

 extern StationModel station;
 extern DeviceList devicelist;
 extern HostList hostlist;
 //extern  QList<SerialPort*> serialList;
 extern PortList portList;
class SerialPortHelper : public QObject
{

    Q_OBJECT

public:

    explicit SerialPortHelper(QObject *parent = nullptr);

    ~SerialPortHelper();


    Q_INVOKABLE QStringList querySerialInfo();
//    Q_INVOKABLE void addDevice(QString name_, QString portname_, QString protocol_, QString addr_);
//    Q_INVOKABLE void addHost(QString name_, QString portname_, QString protocol_, QString addr_);
    Q_INVOKABLE void clickDeviceItem(int index);
    Q_INVOKABLE void clickHostItem(int index);
    Q_INVOKABLE void HostSendAuto(int CN,int hostIndex=-1);
    Q_INVOKABLE void goUpDate();
    //Q_INVOKABLE QList<Device> queryDeviceInfo();
    int GetPortNumByName(QString portname);

signals:



public slots:
        void SoftUpdateDo(const QString &s);

private:
    // 声明一个回调函数
    static void recvDeviceCallBack(int devIndex,QString devName,QString res);
    static void recvHostCallBack(int hostIndex,QString hostName,QString res);
    static void processRecvDeviceBackMsg(int index,QString dev,QString res);
    static void processRecvHostBackMsg(int index,QString host,QString res);
 // QList<Device> device_list;
 //private:
//	static DeviceModle *device_list;

};



#endif // SERIALPORTHELPER_H
